﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;
using MobiMenu.Restaurant.Web.Utility;

namespace MobiMenu.Restaurant.Web
{
    /// <summary>
    ///ResponseData 的摘要说明
    /// </summary>
    [DataContract(Namespace = "MobiMenu.Restaurant.Web")]
    public class ResponseData<T>
    {
        public ResponseData()
        {
        }

        [DataMember(Name = RequestHelper.ErrorKey, EmitDefaultValue = false)]
        public string Error
        {
            get;
            set;
        }

        [DataMember(Name = RequestHelper.SuccessKey)]
        public bool Success
        {
            get;
            set;
        }

        [DataMember(Name = RequestHelper.DataKey, EmitDefaultValue = false)]
        public DataImpl Data
        {
            get;
            private set;
        }

        public DataImpl CreateData()
        {
            return Data = new DataImpl();
        }

        [DataContract(Namespace = "MobiMenu.Restaurant.Web")]
        public class DataImpl
        {
            public DataImpl()
            {
                List = new List<T>();
            }


            [DataMember(Name = RequestHelper.SortFieldKey, EmitDefaultValue = false)]
            public string SortField
            {
                get;
                set;
            }

            [DataMember(Name = RequestHelper.SortByDescKey, EmitDefaultValue = false)]
            public bool? SortByDesc
            {
                get;
                set;
            }

            [DataMember(Name = RequestHelper.PageNoKey, EmitDefaultValue = false)]
            public int? PageNo
            {
                get;
                set;
            }

            [DataMember(Name = RequestHelper.PageSizeKey, EmitDefaultValue = false)]
            public int? PageSize
            {
                get;
                set;
            }

            [DataMember(Name = RequestHelper.TotalKey, EmitDefaultValue = false)]
            public int? Total
            {
                get;
                set;
            }

            [DataMember(Name = RequestHelper.PageCountKey, EmitDefaultValue = false)]
            public int? PageCount
            {
                get;
                set;
            }

            [DataMember(Name = RequestHelper.RowsKey)]
            public List<T> List
            {
                get;
                set;
            }
        }
    }
}